package org.tea.inventory.enums;

import cn.hutool.core.date.DateField;
import lombok.Getter;
import lombok.Setter;

/**
 * @author hanzy
 * @description 积分规则类型
 * @date 2023年04月06日 14:03
 */
public enum IntegralRuleTypeEnum {
    //expireFalg = false 的设置过期时间为99年

    ENTRYPERIOD(10, "入职年限", false, DateField.YEAR, 99),
    //    ALLTSUTOMU(20, "全勤"),
    BIRTHDAY(30, "员工生日", true, DateField.YEAR, 1),
    DEPT_REWARD(31, "部门表彰", true, DateField.YEAR, 1),
    COMPANY_TREWARD(32, "公司表彰", true, DateField.YEAR, 1),
    CUSTOMER_TREWARD(33, "客户表彰", true, DateField.YEAR, 1),
    CERTIFICATE(41, "证书上传", false, DateField.YEAR, 99),
    HOLIDAY_CREDIT(50, "节日积分", false, DateField.YEAR, 99),
    SIGN(60, "签到", false, DateField.YEAR, 99),
    MIDSIGN(61, "中秋签到", false, DateField.YEAR, 99),
    ACTSIGN(62, "活动签到", false, DateField.YEAR, 99),
    GAME(80, "游戏", false, DateField.YEAR, 99),
    ORDER(90, "订单", false, DateField.YEAR, 99),
    WELFARE(95, "福利", false, DateField.YEAR, 99),
    SYS(100, "系统", false, DateField.YEAR, 99),
    TRAIN(110, "培训", false, DateField.YEAR, 99),
    POST(120, "帖子", false, DateField.YEAR, 99),
    PURCHASE(121, "购买积分", false, DateField.YEAR, 99),
    EXPENSE(122, "消费积分", false, DateField.YEAR, 99),
    ;

    @Getter
    @Setter
    private Integer code;
    @Getter
    @Setter
    private String content;

    @Getter
    @Setter
    private boolean expireFalg;//状态
    @Getter
    @Setter
    private DateField dateField;//过期单位
    @Getter
    @Setter
    private int expire;//过期时间

    IntegralRuleTypeEnum(Integer code, String content, boolean expireFalg, DateField dateField, int expire) {
        this.code = code;
        this.content = content;
        this.expireFalg = expireFalg;
        this.dateField = dateField;
        this.expire = expire;
    }

    public static String getContentByName(Integer code) {
        for (IntegralRuleTypeEnum productAttributeEnum : IntegralRuleTypeEnum.values()) {
            if (productAttributeEnum.getCode() == code) {
                return productAttributeEnum.getContent();
            }
        }
        return "";
    }

    //根据code查询数据
    public static IntegralRuleTypeEnum getDataByCode(Integer code) {
        for (IntegralRuleTypeEnum productAttributeEnum : IntegralRuleTypeEnum.values()) {
            if (productAttributeEnum.getCode() == code) {
                return productAttributeEnum;
            }
        }
        return null;
    }
}
